<script type="text/javascript">
function prueba(){
var anos; 
var num = $("#fechaA").val().substring(0,2);
return anos =  $("#fechaA").val().substring(6,10)+','+num+','+$("#fechaA").val().substring(3,5);
   	 
} 
</script>

<?php 
$titulo = @$this->session->flashdata('error_title');
$rauter = $this->session->flashdata('error_router');
?>

<?php if (strlen($titulo) > 0):?>
    <?php if ($rauter == false):
          $style = "errorfalse";
          else:
          $style = "errortrue";
          endif;
    ?>   
<div id="<?php echo $style;?>">
   <?php echo $titulo; ?>
</div>
<?php endif;?>
<script language="javascript">
    // apply filters
    var applyFilter = function()
    {
        
    }
    jQuery(document).ready(function(){
        jQuery("#list").jqGrid({
            url: '<?php echo site_url() ?>/vscampania/data/',
            mtype: 'POST',
            datatype: 'json',
            colNames:['Inbound','Gestor','Fecha','# Campa&ntilde;a','Tipo Salida'],
            colModel :[
                       {name:'Inbound', index:'IdTransaccion', width:10, hidden:true},
                       {name:'Gestor', index:'referencia', width:50},
                       {name:'Fecha', index:'DateSistema', width:10},
                       {name:'Codigo', index:'Campania', width:10},
                       {name:'tipoS', index:'idMotivoSalida', width:10}],
                     
                       
            pager: jQuery('#pager'),
            hiddengrid: true,
            sortname: 'IdTransaccion',
            rowNum:30,       
            rowList:[30,40,50,60,70],
            sortorder: "desc",
            height: '100%',
            width: '710',
            imgpath: _base_url + 'public/css/jqgrid/flex/images',
            viewrecords: true,
            multiselect: false,
            onSelectRow: function(ids) 
            {
            	if(ids != null) 
            	{
            		var rec = jQuery("#list").getRowData(ids);
            		lol=ids;
            	}
            },
            adjacents: 4,
            jsonReader: { repeatitems : false, idAccion: "0" }
        }).navGrid('#pager',{add:false,del:false,edit:false,search:false,position:"left"})
        
         .navButtonAdd('#pager',{caption:"", buttonimg: _base_url + "public/css/jqgrid/flex/images/text_columns.png", onClickButton:function(){ jQuery("#list").setColumns();} })
         
         .navButtonAdd('#pager',{caption:"Generar Excel", buttonimg: _base_url + "public/images/new.png", onClickButton:function(){ window.location = _site_url + "/vscampania/generarXmls"; } })
   
         $('#apply_filter').bind('click', applyFilter);
        
    });

    var flAuto = true;
    var timeoutHnd; 

    function doSearch(ev)
    { 
          if(!flAuto) return; 
          // var elem = ev.target||ev.srcElement; 
          if(timeoutHnd) 
              clearTimeout(timeoutHnd); 
              timeoutHnd = setTimeout(gridReload,500); 
    } 
     
    function enableAutosubmit(state)
    { 
          flAuto = state; 
          jQuery("#submitButton").attr("disabled",state); 
    }

   
    function gridReload()
    { 
   	      
             var mo_mask = jQuery("#search_mo").val(); 
             var ff_mask = jQuery("#search_ff").val();
             
             var fecha_search = mo_mask.replace("/", ".");
			 var fechaF_search = ff_mask.replace("/", ".");
			 
             
             var array_search = fecha_search.replace("/", ".")+'-'+fechaF_search.replace("/", ".");
         	 jQuery("#list").setGridParam({url :'<?php echo site_url() ?>/vscampania/data/'+array_search, page : 1}).trigger('reloadGrid'); 
    }

   
</script>
<div class="table_container">
<table>

    <tr>
    	<td><div id="titulo">Inbound vs Inbound por Campa&ntilde;a</div></td>
    </tr>
  
   <tr>
    	<td style="background: #D9E6F0; border: 1px solid #C3AA64; height: 23px">&nbsp;<b>De:<b/><input type = 'text' id='search_mo' onChange='doSearch(arguments[0]||event)'>&nbsp;<b>Hasta:</b><input type = "text" id = "search_ff" onChange='doSearch(arguments[0]||event)'></td>
        
 		<script type="text/javascript">
                              $(function()
                                {
                                  
                                 $("#search_mo").datepicker({});

									
                                });

                              $(function()
                                      {
                                        
                                       $("#search_ff").datepicker({});

      									
                               });
        </script>
  
   </tr>
    <tr>
        <td>
            <table id="list" class="scroll"></table>
            <div id="pager" class="scroll" style="text-align:center;"></div>
        </td>
	</tr>
	
	
	
 </table>
</div>